from socf.server import discovery
from socf import conf

import unittest
import os

class ConfigurationTest(unittest.TestCase):
    
    def setUp(self):
        pass
        
    def testConf(self):
        #creates configuration context
        configContext = conf.ConfigurationContext(os.path.join(os.getcwd(),  "conf"))
    
        # initialize the user defined device discovery
        d1 = discovery.UserDefinedDiscoveryProvider(configContext)
        devices = d1.getDiscoveredDevices()
        self.assert_(len(devices) > 0)
        print "Devices:-"
        print devices
    
        sr = conf.ServiceRegistry(configContext)
        val = sr.getServiceInfoByType(1)
        self.assert_(not val is None)
        print val[0]
        print val[1]
    
        dr = conf.DeviceTypeRegistry(configContext)    
        dlist = dr.getDeviceTypeList()
        self.assert_(len(dlist) > 0)
        for e in dlist:
            print e.getDescription()

        dr2 = conf.DeviceDriverMappings(configContext)
        dinfo = dr2.getDriverInfoByDevice(devices[1])
        self.assert_(not dinfo is None)
        print dinfo
    
        ds = conf.DriverServiceMappings(configContext) 
        self.assert_(not ds is None)
        print ds.getServiceTypeByDriver("NavigationDriver")


if __name__ == '__main__':
    unittest.main()

